package com.fau.fm.entity;

import java.io.Serializable;

import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.GeneratedValue;
import javax.persistence.Id;
import javax.persistence.Table;
import javax.persistence.Transient;

import org.hibernate.annotations.GenericGenerator;
import org.hibernate.validator.constraints.Length;
import org.hibernate.validator.constraints.NotBlank;
import org.json.simple.JSONAware;
import org.json.simple.JSONObject;

/**
 * @desc 字典表
 * @author liy
 * @datetime 2014年7月29日,下午7:37:15
 */
@Entity
@Table(name = "medical_key_value")
public class MedicalKeyValue implements Serializable,JSONAware {

	private static final long serialVersionUID = -8342665513836776563L;
	
	private String id;
	
	@NotBlank(message = "字典表值不能为空！")
	@Length(max = 20, message = "字典表值长度需要在0和20之间")
	private String keyValue;	// 字典表Value
	
	@NotBlank(message = "字典表类型不能为空！")
	@Length(max = 25, message = "字典表类型长度需要在0和25之间")
	private String typeName;	// 字典表类型
	
	@NotBlank(message = "字典表键不能为空！")
	@Length(max = 20, message = "字典表键长度需要在0和20之间")
	private String keyName;		// 字典表Key
	private String systemType;	// 系统类型
	private String hospitalId;	//医院标识
	
	private String chFieldVal;	// 字段中文含义
	
	@Id
	@GenericGenerator(name = "generator", strategy = "uuid.hex")
	@GeneratedValue(generator = "generator")
	@Column(name = "id", length = 32)
	public String getId() {
		return id;
	}

	public void setId(String id) {
		this.id = id;
	}

	@Column(name = "key_value", length = 60)
	public String getKeyValue() {
		return keyValue;
	}

	public void setKeyValue(String keyValue) {
		this.keyValue = keyValue;
	}

	@Column(name = "type_name", length = 25)
	public String getTypeName() {
		return typeName;
	}

	public void setTypeName(String typeName) {
		this.typeName = typeName;
	}

	@Column(name = "key_name", length = 20)
	public String getKeyName() {
		return keyName;
	}

	public void setKeyName(String keyName) {
		this.keyName = keyName;
	}

	@Column(name = "system_type", length = 5)
	public String getSystemType() {
		return systemType;
	}

	public void setSystemType(String systemType) {
		this.systemType = systemType;
	}

	@Column(name = "hospital_id", length = 32)
	public String getHospitalId() {
		return hospitalId;
	}

	public void setHospitalId(String hospitalId) {
		this.hospitalId = hospitalId;
	}
	
	@Transient
	public String getChFieldVal() {
		return chFieldVal;
	}

	public void setChFieldVal(String chFieldVal) {
		this.chFieldVal = chFieldVal;
	}

	@SuppressWarnings("unchecked")
	@Override
	public String toJSONString() {
		JSONObject obj = new JSONObject();
		obj.put("id", id);
		obj.put("keyValue", keyValue);
		obj.put("typeName", typeName);
		obj.put("keyName", keyName);
		obj.put("chFieldVal", chFieldVal);
		return obj.toString();
	}

}
